package com.akgroup.ticketease.member.controller;

import com.akgroup.common.resp.CommonResp;
import com.akgroup.ticketease.member.req.MemberRegisterReq;
import com.akgroup.ticketease.member.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author 孤霜
 * @version 1.0
 */
@RestController
@RequestMapping("/member")
public class MemberController {
    @Autowired
    private MemberService memberService;

    @GetMapping("/count")
    public CommonResp<Long>  count(){
        CommonResp<Long> commonResp = new CommonResp<>();
        Long count = memberService.count();
        commonResp.setContent(count);
        return commonResp;
    }

    @PostMapping("/register")
    public CommonResp<Long> register(@Valid MemberRegisterReq req){
        long register = memberService.register(req);
        CommonResp<Long> commonResp = new CommonResp<>();
        commonResp.setContent(register);
        return commonResp;
    }
}
